package com.lxmes.base.service.impl;

import java.util.List;
import com.lxmes.common.utils.DateUtils;
import com.lxmes.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lxmes.base.mapper.JcRuleFormulaMapper;
import com.lxmes.base.domain.JcRuleFormula;
import com.lxmes.base.service.IJcRuleFormulaService;

/**
 * 规则公式Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-09
 */
@Service
public class JcRuleFormulaServiceImpl implements IJcRuleFormulaService 
{
    @Autowired
    private JcRuleFormulaMapper jcRuleFormulaMapper;

    /**
     * 查询规则公式
     * 
     * @param ruleId 规则公式主键
     * @return 规则公式
     */
    @Override
    public JcRuleFormula selectJcRuleFormulaByRuleId(Long ruleId)
    {
        return jcRuleFormulaMapper.selectJcRuleFormulaByRuleId(ruleId);
    }

    /**
     * 查询规则公式列表
     * 
     * @param jcRuleFormula 规则公式
     * @return 规则公式
     */
    @Override
    public List<JcRuleFormula> selectJcRuleFormulaList(JcRuleFormula jcRuleFormula)
    {
        return jcRuleFormulaMapper.selectJcRuleFormulaList(jcRuleFormula);
    }

    /**
     * 新增规则公式
     * 
     * @param jcRuleFormula 规则公式
     * @return 结果
     */
    @Override
    public int insertJcRuleFormula(JcRuleFormula jcRuleFormula)
    {
        jcRuleFormula.setCreateTime(DateUtils.getNowDate());
        jcRuleFormula.setCreateBy(SecurityUtils.getUsername());
        jcRuleFormula.getRuleContent().replace("<p>","");
        jcRuleFormula.getRuleContent().replace("</p>","");
        return jcRuleFormulaMapper.insertJcRuleFormula(jcRuleFormula);
    }

    /**
     * 修改规则公式
     * 
     * @param jcRuleFormula 规则公式
     * @return 结果
     */
    @Override
    public int updateJcRuleFormula(JcRuleFormula jcRuleFormula)
    {
        jcRuleFormula.setUpdateTime(DateUtils.getNowDate());
        return jcRuleFormulaMapper.updateJcRuleFormula(jcRuleFormula);
    }

    /**
     * 批量删除规则公式
     * 
     * @param ruleIds 需要删除的规则公式主键
     * @return 结果
     */
    @Override
    public int deleteJcRuleFormulaByRuleIds(Long[] ruleIds)
    {
        return jcRuleFormulaMapper.deleteJcRuleFormulaByRuleIds(ruleIds);
    }

    /**
     * 删除规则公式信息
     * 
     * @param ruleId 规则公式主键
     * @return 结果
     */
    @Override
    public int deleteJcRuleFormulaByRuleId(Long ruleId)
    {
        return jcRuleFormulaMapper.deleteJcRuleFormulaByRuleId(ruleId);
    }
}
